package com.util;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * Created by asan on 2015-06-13.
 */
public class LoginTicketUtil {

    public static String getTicket(Integer id)
    {
       return DigestUtils.md5Hex(id+SystemConstant.LOGIN_TICKET_SECRET);
    }
    public static String getTicket(Integer id,Integer shopId)
    {
        return DigestUtils.md5Hex(shopId+"_"+id+SystemConstant.LOGIN_TICKET_SECRET);
    }
    public static boolean validateTicket(Integer id,String ticket)
    {
        return getTicket(id).equals(ticket);
    }
    public static boolean validateTicket(Integer id,Integer shopId,String ticket)
    {
        return getTicket(id,shopId).equals(ticket);
    }
}
